<template>
  <view class="content">
    <view class="box flexs11">
      <scroll-view :scroll-y="true"
                   class="scroll-Y left">
        <view :class="type==index?'left_list flexs1':'left_list_new flexs1'"
              v-for="(item,index) in classList"
              :key="index"
              @click="choose(index)">
          <view :class="type==index?'line':''"></view>
          <view class="title">{{item.name}}</view>
        </view>
      </scroll-view>
      <scroll-view :scroll-y="true"
                   class="scroll-Y right">
        <view class="right_box">
          <view class="right_list"
                v-show="second_list.length!=0">
            <view class="right_item" 
                  v-for="(item,index) in second_list"
                  :key="index"
                  @click="goClass(item.id)">
              {{item.name}}
            </view>
          </view>
        </view>
      </scroll-view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      type: 0,
      classList: [],
      second_list: []
    }
  },
  onLoad() {
    this.getClassList()
  },
  methods: {
    choose(type, id) {
      this.type = type
      this.second_list = this.classList[type].second_list
    },
    goClass(id) {
      uni.navigateTo({
        url: 'brush_type?classid=' + id
      })
    },
    getClassList() {
      var obj = {
        type_id: this.typeindex
      }
      this.$http.post('/subject_class/index', obj).then((res) => {
        if (res.data.code == 1) {
          this.classList = res.data.data
          this.second_list = this.classList[0].second_list
        }
      })
    }
  }
}
</script>

<style>
.content {
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.box {
  width: 100%;
  height: 100%;
  border-top: 1rpx solid #e5e5e5;
  display: flex;
}

.left {
  width: 210rpx;
  height: 100vh;
}

.left_list {
  width: 210rpx;
  height: 110rpx;
  background-color: #ffffff;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.left_list_new {
  width: 210rpx;
  height: 110rpx;
  background-color: #f2f2f2;
  display: flex;
  line-height: 55rpx;
  align-items: center;
}

.line {
  width: 4rpx;
  height: 20rpx;
  background: #ffdd47;
  border-radius: 2rpx;
}

.title {
  width: 170rpx;
  text-align: center;
  color: #333333;
  font-size: 24rpx;
}

.right {
  width: 600rpx;
  height: 100vh;
}

.right_box {
  width: 100%;
  height: 100%;
  background-color: #ffffff;
  border-top: solid 1rpx #ffffff;
  flex-wrap: wrap;

  padding: 0 20rpx;
}
.right_list {
  margin-top: 0rpx;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 40rpx;
}
.right_item {
  padding: 15rpx 22rpx;
  border: 1rpx solid #cccccc;
  border-radius: 10rpx;
  margin: 15rpx 10rpx;
}
</style>
